package controller;

import entity.User;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vo.AjaxResult;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Author：汤小洋
 * Date：2023-07-05 15:16
 * Description：<描述>
 */
// @Controller
// @ResponseBody
@RestController
// @CrossOrigin
public class AjaxController {

    // @ResponseBody
    @RequestMapping("/ajax1")
    public User ajax1(){
        System.out.println("AjaxController.ajax1.........");
        User user = new User(1, "小洋", "123", 18, 1.88, new Date());
        return user;
    }

    // @ResponseBody
    @RequestMapping("/ajax2")
    public AjaxResult ajax2(){
        System.out.println("AjaxController.ajax1.........");

        // User user = new User(1, "小洋", "123", 18, 1.88, new Date());

        List<User> users = new ArrayList<>();
        users.add(new User(1, "小洋", "123", 18, 1.88, new Date()));
        users.add(new User(2, "小跃", "123", 18, 1.88, new Date()));
        users.add(new User(3, "小鹏", "123", 18, 1.88, new Date()));

        return AjaxResult.success(users);
    }


}
